import time
def bb_sort(nums):
    sw=True
    while sw:
        sw=False
        for i in range(len(nums)-1):
            if nums[i] >nums[i+1]:
                nums[i],nums[i+1] = nums[i+1], nums[i]
                sw=True
def read_l(filename):
    file =open(filename,"r")
    data = file.readlines()
    return data
m1=read_l("m1_sorted.txt")
m2=read_l("m2_reverse.txt")
m3=read_l("m3_shuffle.txt")

t_s=time.time()
bb_sort(m1)
t_f=time.time()
t_w=t_f-t_s
print("m1_sorted.txt",round(t_w*1000), "milliseconds")
t_s=time.time()
bb_sort(m2)
t_f=time.time()
t_w=t_f-t_s
print("m2_reverse.txt",round(t_w*1000), "milliseconds")
t_s=time.time()
bb_sort(m3)
t_f=time.time()
t_w=t_f-t_s
print("m3_shuffled.txt",round(t_w*1000), "milliseconds")



